﻿<?php
	error_reporting(E_ALL^E_NOTICE);
	require_once ('./config/config.php'); 
	require_once ('./class/email.class.php'); 
	require_once ('./class/tools.class.php');
	date_default_timezone_set("PRC");
	session_start();
	if(!empty($_SESSION['user'])){
		echo "<script>location='./index.php';</script>";
		exit();
	}else{
		if($_POST){
			$user=$_POST['user'];
			$pwd=sha1($_POST['pwd']);
			if(empty($user) or empty($pwd)){
				echo "<script>alert('请输入完整信息！');location='./login.php';</script>";
				exit();
			}else{
				$userRs=mysqli_fetch_array(mysqli_query($con,"select * from user where user='".$user."'"));
				if($userRs['password']==$pwd){
					if($userRs['state']=="1"){
						$_SESSION['user']=$userRs['user'];
						echo "<script>location='./index.php';</script>";
						exit();
					}else{
						echo "<script>alert('帐号状态异常，暂时无法为您提供服务！');location='./login.php';</script>";
						exit();
					}
				}else{
					echo "<script>alert('账户与密码不匹配，请检查后重试！');location='./login.php';</script>";
					exit();
				}
			}
		}
	}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>某高校图书共享系统 - 用户登录</title>
		<link rel="stylesheet" href="./auth-assets/css/reset.css" />
		<link rel="stylesheet" href="./auth-assets/css/common.css" />
	</head>
	<body>
		<div class="wrap login_wrap">
			<div class="content">
				
				<div class="logo"></div>
				
				<div class="login_box">	
					
					<div class="login_form">
						<div class="login_title">
							登录
						</div>
						<form action="" method="post">
							
							<div class="form_text_ipt">
								<input name="user" type="text" placeholder="请输入帐号">
							</div>
							<div class="ececk_warning"><span>数据不能为空</span></div>
							<div class="form_text_ipt">
								<input name="pwd" type="password" placeholder="请输入密码">
							</div>
							<div class="ececk_warning"><span>数据不能为空</span></div>
							<div class="form_btn">
								<button type="submit">登录</button>
							</div>
							<div class="form_reg_btn">
								<span>还没有帐号？</span><a href="./reg.php">马上注册</a>
							</div>
						</form>
						<div class="other_login">
							<div class="left other_left">
								<span>其它登录方式</span>
							</div>
							<div class="right other_right">
								<a href="">华宇通行证</a>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript" src="./auth-assets/js/jquery.min.js" ></script>
		<script type="text/javascript" src="./auth-assets/js/common.js" ></script>
</body>
</html>